在本系列 【Day 17】 私有 Quay Registry 與 oc mirror 提到用 oc-mirror
oc-mirror,不過因為開發需求,要使用乾坤大挪移時會很麻煩。git clone https://github.com/openshift/oc-mirror
Dockerfile,內容如下:
# 使用 Red Hat UBI 基礎映像
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
# 設定工作目錄
WORKDIR /usr/local/bin
# 複製 oc-mirror binary (需自行放到 build context)
COPY oc-mirror /usr/local/bin/oc-mirror
# 確保 binary 有執行權限
RUN chmod +x /usr/local/bin/oc-mirror
# 預設工作目錄 (給使用者掛載 config/output)
WORKDIR /workspace
# 預設 entrypoint
ENTRYPOINT ["oc-mirror"]
# 假設 Dockerfile 與 oc-mirror binary 在同一個目錄
docker build -t oc-mirror:latest .
docker run --rm -it oc-mirror:latest version
oc-mirror 沒有原生 macOS ARM 版本。| 方法 | 描述 | 難度 | 效能 | 適合誰 |
|---|---|---|---|---|
| 🧰 Podman x86_64 VM (官方推薦) | 用 Podman Machine 啟動一台 x86_64 Linux VM | ★★★ | 🐢 較慢 (QEMU 模擬) | 想保留 Red Hat 原生環境的使用者 |
| 🐳 Docker Desktop + amd64 容器 | 用 Docker Desktop 的 “Use Rosetta for x86/amd64” 功能 | ★★☆ | ⚡ 普通 | 已安裝 Docker Desktop |
| 🖥️ UTM / Lima 直接啟動 x86_64 Linux VM | 用 UTM 建一台 CentOS/RHEL VM,裡面跑 oc-mirror | ★★ | ⚡⚡ 快 | 想長期離線維護鏡像的人 |
podman machine stop
podman machine rm -f
podman machine init --now --cpus=4 --memory=8192 --disk-size=40 --image-path /path/to/podman-machine.qcow2 --vm-type qemu --qemu-args "-machine accel=tcg" --arch x86_64
podman machine ssh
curl -L https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/stable/oc-mirror.tar.gz -o oc-mirror.tar.gz
tar -xzf oc-mirror.tar.gz
chmod +x oc-mirror
./oc-mirror version
podman machine ssh "mkdir -p /work"
podman mount <container_id>
docker run --rm -it \
-v $(pwd)/config.yaml:/config.yaml \
-v $(pwd)/mirror-data:/mirror-data \
oc-mirror:latest --config /config.yaml file://mirror-data